<?php

namespace seecms\controller;

use seecms\lib\builder\query\DatetimeQuery;
use seecms\lib\builder\query\SelectQuery;
use seecms\See;
use seecms\SeeLang;

class UserLoginLog extends Resource
{

    protected $table_name = 'see_user_login';

    protected $dictionary_name = 'user_login';

    protected $actions = [];

    protected function pageTitle(): string
    {
        return __('user_login.page_title');
    }

    protected function leftToolbars(): array
    {
        return [];
    }

    public function query(): array
    {
        $users = See::table()->user->order('id desc')->column('nickname', 'id');

        return [
            SelectQuery::init('user_id')->setOptions($users)->setPlaceholder(SeeLang::user('select_user')),
            DatetimeQuery::init('created_at'),
        ];
    }

    public function columns(): array
    {
        return [
            'id',
            'user_id',
            'ip',
            'browser',
            'device',
            'platform',
            'is_mobile_text',
            'status_text',
            'reason',
            'user_agent',
            'created_at',
        ];
    }

    public function readControls(): array
    {
        return [
            'nickname',
            'avatar.false',
            'phone.false',
            'email.false',
        ];
    }

    public function controls(): array
    {
        return [
            'username',
            'password',
            'confirm_password',
            'nickname',
            'avatar.false',
            'phone.false',
            'email.false',
        ];
    }
}